﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Admin_ResetPassword : System.Web.UI.Page
{
    AddminMethord AM = new AddminMethord();
    
    string InterviewerID = "";
    string HRID = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            InterviewerID= Request.QueryString["ID"];
            if ((Request.QueryString["HRID"]== null))
            {
                InformationInterviewer();
                btnCancel.PostBackUrl = "AdminViewInforInterviewer.aspx?ID=" + txtUserName.Text; 
            }
            else
            {
                HRID = Request.QueryString["HRID"];
                InformationHR();
                btnCancel.PostBackUrl = "AdminViewEmployeeInfor.aspx?ID=" + txtUserName.Text;
            }
        }
        catch (Exception ex)
        {
        }
    }
    public void InformationHR() 
    {
        try
        {
            DataTable tb = AM.HRinformation(HRID.ToString());
            if(tb.Rows.Count > 0)
            {
                txtUserName.Text = tb.Rows[0]["UserName"].ToString();
                txtFullName.Text = tb.Rows[0]["FullName"].ToString();
                txtAddress.Text = tb.Rows[0]["Address"].ToString();
                txtPhone.Text = tb.Rows[0]["Phone"].ToString();
                txtBirthOfDate.Text = tb.Rows[0]["BirthOfDate"].ToString().Substring(0, tb.Rows[0]["BirthOfDate"].ToString().IndexOf(" "));
                txtEmail.Text = tb.Rows[0]["EmailID"].ToString();
            }
        }
        catch (Exception ex)
        {
        }
    }
    public void InformationInterviewer() {
        
        DataTable tb = AM.InterviewInfomation(InterviewerID.ToString());
        if(tb.Rows.Count > 0){
            txtUserName.Text = tb.Rows[0]["InterViewerID"].ToString();
            txtFullName.Text = tb.Rows[0]["FullName"].ToString();
            txtAddress.Text = tb.Rows[0]["Address"].ToString();
            txtPhone.Text = tb.Rows[0]["Phone"].ToString();
            txtBirthOfDate.Text = tb.Rows[0]["BirthOfDate"].ToString().Substring(0,tb.Rows[0]["BirthOfDate"].ToString().IndexOf(" "));
            txtEmail.Text = tb.Rows[0]["EmailID"].ToString();
        }
    }
    public void ResetPasInterviewer() {
        bool check = AM.ResetPassInterviewer(InterviewerID.ToString());
        if (check)
        {
            lblErros.Text = "Reset Pasword Succsessfully";
        }
        else
        {
            lblErros.Text = "Reset Pasword UNSuccsessfully";
        }
       
    }
    public void resetPasHR() {
        bool check = AM.ResetPassHR(HRID.ToString());
        if (check)
        {
            lblErros.Text = "Succsessfully";
        }
        else
        {
            lblErros.Text = "UNSuccsessfully";
        }
        
    }
    protected void btnReset_Click(object sender, EventArgs e)
    {
        if ((Request.QueryString["HRID"] == null))
        {
            ResetPasInterviewer();

        }
        else
        {
            HRID = Request.QueryString["HRID"];
            resetPasHR();
        }
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
    }
}